package main

import "fmt"

func main() {
	input := []int{1, 2, 3, 4, 5, 6, 7}
	len := removeDuplicates(input)
	for i := 0; i < len; i++ {
		fmt.Print(" ", input[i])
	}
}

func removeDuplicates(nums []int) int {
	if len(nums) == 0 {
		return 0
	}
	index := 0
	for i := 1; i < len(nums); i++ {
		if nums[i] == nums[i-1] {
			continue
		}
		index++
		nums[index] = nums[i]
	}
	return index + 1
}
